export const state = () => {
    return {
        data: [],
        totals: 0
    }
}
export const mutations = {
    SET_LIST(state, v) {
        state.data = v.data
        state.totals = v.total
    },

}

export const actions = {
    async getData({ commit }, row) {
        console.log(row)
        if (row) {
            const { data } = await this.$axios.get(`http://localhost:3001/msbd/msbd-list?pageSize=${row.pageSize}&page=${row.page}&sortBy=true`)
            console.log(data)
            commit('SET_LIST', data)
        } else {
            const { data } = await this.$axios.get('http://localhost:3001/msbd/msbd-list?pageSize=10&sortBy=true')
            console.log(data)
            commit('SET_LIST', data)
        }
    },
    async addData({ dispatch }, row) {
        const r = await this.$axios.post('http://localhost:3001/msbd/save-msbd', row)
    },
    async editData({ }, row) {
        await this.$axios.post('http://localhost:3001/msbd/update-msbd', row)
    },
    async delData({ }, row) {
        console.log(row)
        await this.$axios.get(`http://localhost:3001/msbd/delete-msbd?id=${row}`)
    }
}

export const getters = {

}